package cn.wolfcode.mq;

import cn.wolfcode.service.IOrderInfoService;
import cn.wolfcode.service.ISeckillProductService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

//@Component
@RocketMQMessageListener(consumerGroup = "timeoutGroup",topic = MQConstant.ORDER_PAY_TIMEOUT_TOPIC)
public class OrderTimeoutQueueListener implements RocketMQListener<String> {
    @Autowired
    private IOrderInfoService orderInfoService;
    @Override
    public void onMessage(String orderNo) {
        // 修改订单的状态并且回补库存,两个动作为原子性操作
        orderInfoService.cancelOrderAndFallbackStockCount(orderNo);
    }
}
